<?php
namespace Www\Controller;
use Think\Controller;
class DtmallController extends Controller {



	public function index(){

        $token =$this->getToken();
        echo $token;
	}



    private function getToken(){

//        $token =S('TAMLL_TOKEN');
//        if (empty($token)){
            $apiurl ="http://rest2.dtshop.com/Auth/token";
            $data = array();

            // $data["appid"] = 16;
            // $data["access_key"] = "e807f1fcf82d132f9bb018ca6738a19f";
            // $data["secret_key"] = "6ebe76c9fb411be97b3b0d48b791a7c9";
            // $data["sign_code"] = "25d55ad283aa400af464c76d713c07ad";

//            $data["appid"] = 20;
//            $data["access_key"] = "e807f1fcf82d132f9bb018ca6738a19f";
//            $data["secret_key"] = "6ebe76c9fb411be97b3b0d48b791a7c9";
//            $data["sign_code"] = "d1ff7aeed0938a52c3221b2b5fd22723";

             //本地
             $data["appid"] = 18;
             $data["access_key"] = "c8fe9abaaed3d038ecd2b057a9575c44";
             $data["secret_key"] = "a979631629e8079bf4229b4f3a71c24a";
             $data["sign_code"] = "80d46f06495b16a0b53fe3d00df18b6a";


            $data["device_id"] = "0000000000000000";
            $data["erp_uid"] = session_id();
//            $nfield = "device_id,erp_uid";
//            $return_array = true;
            $data['sign'] =_sign($data);
            $res =json_decode(curl_post($apiurl,$data),true);
            file_put_contents('./111.txt',var_export($data,true));
//            print_r($res);
//            exit;
//            if (!empty($res) && $res['code']==1){
//                S('TAMLL_TOKEN',$res['data']['token'],3600);
                return $res['data']['token'];
//            }
//        }
      //  return $token;
    }

    public function index3(){

        echo "12345678: ". self::getSuperMD5('12345678')."<br>";
        echo "a12345678: ". self::getSuperMD5('a12345678')."<br>";
        echo "123456789: ". self::getSuperMD5('123456789')."<br>";

    }


    //得到高强度不可逆的加密字串
    public static function getSuperMD5($str) {
        return MD5(SHA1($str) . '@$^^&!##$$%%$%$$^&&asdtans2g234234HJU');
    }


    public function sendCoupones(){

            $apiurl ="http://rest2.dttxbox.com/GameCoupons/sendCoupons";
            $data = array();
            $data["uid"] = '3e7ff4b550c52c5e266dafe991dee9bc';
            $data["batchSn"] = "YT201710121111482785641536";
            $data["token"] = "43d96b0273d590203e89c0d0bad3bae8";
            $res =json_decode(curl_post($apiurl,$data),true);
            debug(json_encode($res));
    }

    public function cha(){

            $apiurl ="http://rest2.dtmall.com/GameCoupons/CouponsBetchDetail";
            $data = array();
            $data["batchSn"] = "YT201710121111482785641536";
            $data["token"] = "43d96b0273d590203e89c0d0bad3bae8";
            $res =json_decode(curl_post($apiurl,$data),true);
            debug(json_encode($res));
    }

}